/**
 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
 */
// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {
	
	// 参数配置对象
	let config = vm.vuex_config;
	config.adminPath = config.baseUrl
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		// 基础服务：登录登出、身份信息、菜单授权、切换系统、字典数据等
		lang: (params = {}) => vm.$u.get('/lang/'+params.lang),
		index: (params = {}) => vm.$u.get(config.adminPath+'/mobile/index', params),
		getUserInfo: (params = {}) => vm.$u.get(config.adminPath+'/mobile/user/getUserInfo', params),
		getInfo: (params = {}) => vm.$u.get(config.adminPath+'/getInfo', params),
		login: (params = {}) => vm.$u.post(config.adminPath+'/mobile/login/loginByPassword', params),
		wxLogin: (params = {}) => vm.$u.post(config.adminPath+'/mobile/login/wxLogin', params),
		phone: (params = {}) => vm.$u.post(config.adminPath+'/mobile/login/phone', params),
		sendCode: (params = {}) => vm.$u.post(config.adminPath+'/mobile/login/sendCode', params),
		registerUser: (params = {}) => vm.$u.post(config.adminPath+'/mobile/user/registerUser', params),
		//首页相关api
		getIndexCardInfo: (params = {}) => vm.$u.get(config.adminPath+'/mobile/index/getIndexCardInfo', params),
		getM2mOrderFlowList: (params = {}) => vm.$u.get(config.adminPath+'/mobile/index/getM2mOrderFlowList', params),
		//获取卡可购买套餐包
		getM2mOrderPackageList: (params = {}) => vm.$u.get(config.adminPath+'/mobile/index/getM2mOrderPackageList', params),
		
		logout: (params = {}) => vm.$u.get(config.adminPath+'/mobile/login/logout', params),
		authInfo: (params = {}) => vm.$u.get(config.adminPath+'/authInfo', params),
		menuTree: (params = {}) => vm.$u.get(config.adminPath+'/menuTree', params),
		switchSys: (params = {}) => vm.$u.get(config.adminPath+'/switch/'+params.sysCode),
		dictData: (params = {}) => vm.$u.get(config.adminPath+'/system/dict/data/type/'+params.dictType),
		
		// 账号服务：验证码接口、忘记密码接口、注册账号接口等
		validCode: (params = {}) => vm.$u.getText('/validCode', params),
		getFpValidCode: (params = {}) => vm.$u.post('/account/getFpValidCode', params),
		savePwdByValidCode: (params = {}) => vm.$u.post('/account/savePwdByValidCode', params),
		getRegValidCode: (params = {}) => vm.$u.post('/account/getRegValidCode', params),
		saveRegByValidCode: (params = {}) => vm.$u.post('/account/saveRegByValidCode', params),
		
		// APP公共服务
		upgradeCheck: () => vm.$u.post('/app/upgrade/check', {appCode: config.appCode, appVersion: config.appVersion}),
		commentSave: (params = {}) => vm.$u.post('/app/comment/save', params),
		
		// 个人信息修改
		user: {
			saveUserInfo: (params = {}) => vm.$u.post(config.adminPath+'/mobile/user/saveUserInfo', params),
			infoSavePwd: (params = {}) => vm.$u.put(config.adminPath+'/system/user/profile/updatePwd', params),
			infoSavePqa: (params = {}) => vm.$u.post(config.adminPath+'/sys/user/infoSavePqa', params),
		},
		
		// 员工用户查询
		empUser: {
			listData: (params = {}) => vm.$u.get(config.adminPath+'/sys/empUser/listData', params),
		},
		
		// 组织机构查询
		office: {
			treeData: (params = {}) => vm.$u.get(config.adminPath+'/sys/office/treeData', params),
		},
		
		// 增删改查例子
		testData: {
			form: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/form', params),
			list: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/listData', params),
			save: (params = {}) => vm.$u.postJson(config.adminPath+'/test/testData/save', params),
			disable: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/disable', params),
			enable: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/enable', params),
			delete: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/delete', params),
		},
		//财务对账
		financialList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizcustomerpayable/list', params),
		afterSaleOrderList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizAfterSaleOrder/appletList', params),
		// 工序交接
		appletProcessList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrder/appletProcessList', params),
		getProductDetailList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrderProduct/getProductDetailList', params),
		getProductPlanDetail: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrderProcessRecord/appletList', params),
		addRecord: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizOrderProcessRecord/addRecord', params),
		// 仓位
		getSpaceList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizWarehouseSpace/appletList', params),
		// 成品仓位
		getProductSpaceList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizProductWarehouse/appletList', params),
		// 仓库(有库存)
		allListByProductId: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizWarehouse/allListByProductId/' + params.productId),
		// 仓库（所有
		allWarehouseList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizWarehouse/allList'),
		// 根据仓库获取仓位
		spaceListByWarehouseId: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizWarehouseSpace/listByWarehouseId/'+ params.warehouseId),
		
		// 根据仓库和产品id获取有库存仓位
		spaceListByProductId: (params = {}) => vm.$u.get(config.adminPath+`/biz/bizWarehouseSpace/spaceList/${params.warehouseId}/${params.productId}`),
		getInventory: (params = {}) => vm.$u.get(config.adminPath+`/biz/bizProductInventory/list`,params),
		
		// 保存成品仓位
		saveWarehouse: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizOrder/saveWarehouse', params),
		// 
		// /biz/bizWarehouseSpace/list
		// 售后帮助
		AftermarketAppletList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrder/AftermarketAppletList', params),
		bizAfterSaleOrder: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizAfterSaleOrder', params),
		updateBizAfterSaleOrder: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizAfterSaleOrder/updateAppletAfterSaleOrder', params),
		getBizAfterSaleOrder: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizAfterSaleOrder/info/' + params.orderId),
		// 生产领料
		pickingList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrder/pickingList', params),
		bizOrderMaterialList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrderMaterial/detailList/' + params.id),
		saveMaterials: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizOrderMaterial/saveMaterials', params),
		// 商品列表(已过滤无库存)
		bizProductList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizProductInventory/detailList', params),
		// 商品列表（所有）
		bizProductAllList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizProduct/appletList', params),
		// 商品分类
		listTree: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizProductCategory/appletListTree/3/0', params),
		
		// 派工
		vehicleDispatchList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrder/vehicleDispatchList', params),
		updateInstallStatus: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizOrderInstaller/updateStatus', params),
		// 配件信息
		addAccessory: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizOrderAccessory/addAccessory ', params),
		editAccessory: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizOrderAccessory/editAccessory', params),
		// 测量单
		addMeasure: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizMeasure/appletAdd', params),
		// editAccessory: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizOrderAccessory/editAccessory', params),
		bizOrderAccessoryList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrderAccessory/appletList', params),
		bizOrderAccessoryInfo: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrderAccessory/'+params.id),
		// 库存发货
		changeBizOrder: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrder/change/' + params.id + ':' + params.status),
		// 修改发货状态
		shipmentsStatus: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizOrder/shipments', params),
		
		// 测量单
		bizMeasureList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizMeasure/appletList', params),
		updateBizMeasure: (params = {}) => vm.$u.postJson(config.adminPath+'/biz/bizMeasure/updateMeasureStatus', params),
		// 销售订单
		bizOrderList: (params = {}) => vm.$u.get(config.adminPath+'/biz/bizOrder/appletList', params),
		// 所有员工
		bizUserAllList: (params = {}) => vm.$u.get(config.adminPath+'/system/user/appletList', params),
		
		
	};
	
}

export default {
	install
}